package com.gec.hawaste.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.hawaste.entity.WorkOrder;
import com.gec.hawaste.mapper.WorkOrderMapper;
import com.gec.hawaste.service.IWorkOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gec.hawaste.vo.WorkOrderDo;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenxys
 * @since 2022-07-01
 */
@Service
public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder> implements IWorkOrderService {

    @Override
    public IPage<WorkOrderDo> selectByCondition(IPage<WorkOrderDo> page, Map<String, Object> params) {
        QueryWrapper<WorkOrderDo> queryWrapper = new QueryWrapper<>();
        queryWrapper.apply(" wo.del_flag=0 ")
                .gt(params.containsKey("startDate") && !ObjectUtils.isEmpty(params.get("startDate")),"wo.create_date",params.get("startDate"))
                .lt(params.containsKey("endDate") && !ObjectUtils.isEmpty(params.get("endDate")),"wo.create_date",params.get("endDate"))
                .eq(params.containsKey("status") && !ObjectUtils.isEmpty(params.get("status")),"wo.status",params.get("status"));
        return baseMapper.selectByCondition(page,queryWrapper);
    }
}
